<%@ page import="java.util.*"%>
<%@ page import="Model.Wall.*"%>
<%@ page import="DBAccess.DBAccess"%>
<%@ page import="java.sql.PreparedStatement"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="java.sql.SQLException"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Wall</title>
<link href="css/wall.css" rel="stylesheet" type="text/css">
<!-- <meta http-equiv="Refresh" content="30"> -->
	<script type="text/javascript"
		src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
	<script type="text/javascript" src="js/jquery.oembed.js"></script>
	<script>
	var timer = setInterval(function() { $('#content').load('wallContent.jsp'); }, 8000);
	</script>


	<script>

	$(document).ready(function() 
	{
	// Update Status
	$(".update_button").click(function() 
	{
	var updateval = $("#update").val();
	//var dataString = 'update='+ updateval;
	if(updateval=='')
	{
	alert("Please Enter Some Text");
	}
	else
	{
	$("#flash").show();
	$("#flash").fadeIn(400).html('Posting message...');

	$("#flash").fadeOut('slow');
	$.getJSON('/UBCDatingServer/postMessageServlet?updateval='+updateval,  function() {
// 		  alert("success");
	}); 
	}
		});
		
	//commment Submit

	$('.comment_button').live("click",function() 
	{

	var ID = $(this).attr("id");

	var comment= $("#ctextarea"+ID).val();
	var dataString = 'comment='+ comment + '&postID=' + ID;

	if(comment=='')
	{
	alert("Please Enter Comment Text");
	}
	else
	{
	$.ajax({
	type: "POST",
	url: "comment_ajax.php",
	data: dataString,
	cache: false,
	success: function(html){
	$("#commentload"+ID).append(html);
	$("#ctextarea"+ID).val('');
	$("#ctextarea"+ID).focus();
	 }
	 });
	}
	return false;
	});
	// commentopen 
	$('.commentopen').live("click",function() 
	{
	var ID = $(this).attr("id");
	$("#commentbox"+ID).slideToggle('slow');
	return false;
	});	

	// delete comment
	$('.stcommentdelete').live("click",function() 
	{
	var ID = $(this).attr("id");
	var dataString = 'commentID='+ ID;

	if(confirm("Sure you want to delete this update? There is NO undo!"))
	{

	$.ajax({
	type: "POST",
	url: "delete_comment_ajax.php",
	data: dataString,
	cache: false,
	success: function(html){
	 $("#stcommentbody"+ID).slideUp();
	 }
	 });

	}
	return false;
	});
		// delete update
	$('.stdelete').live("click",function() 
	{
	var ID = $(this).attr("id");
	//var dataString = 'postID='+ ID;

	if(confirm("Sure you want to delete this post? There is NO undo!"))
	{

	//$.ajax({
	//type: "POST",
	//url: "delete_message_ajax.php",
	//data: dataString,
	//success: function(html){
	// $("#stbody"+ID).slideUp();
	// }
	// });
		
		$.getJSON('/UBCDatingServer/deletePostServlet?id='+ID, function(html){
			 $("#stbody"+ID).slideUp();
		 });
	}
	return false;
	});
	});
	
	</script>
</head>


<body>
	<div id="wall_container">
		<div id="updateboxarea">
			<h3>Wall</h3>
			<form method="post" action="">
				<textarea cols="30" rows="4" name="update" id="update"
					maxlength="200"></textarea>
				<br /> <input type="submit" value=" Update " id="update_button" class="update_button" />
			</form>
		</div>
		<div id='flashmessage'>
			<div id="flash" align="left"></div>
		</div>
		
		<div id ='content'>
		<%@ include file="wallContent.jsp" %>
		</div>
		
		</div>
	</div>
</body>
</html>


